package com.gmall.gmall2022logger;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
public class controller {
    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    //获取APPlog数据
    @RequestMapping("applog")
    public String getlog(@RequestParam("param") String jsonStr){
        //打印数据看看
        //打印数据
        System.out.println(jsonStr);

        //将数据落盘
        //log.debug(jsonStr);
        log.info(jsonStr);
        //log.warn(jsonStr);
        //log.error(jsonStr);
        //log.trace(jsonStr);

        //将数据写入kafka
        kafkaTemplate.send("ods_base_log",jsonStr);

        return "success";
    }



}
